//@version: $Id: Shape.h 141 2010-12-09 00:23:14Z rujinxero $

/***************************
Shape Class

Group 2:
G
Ron
Jon
Kevin
****************************/
#pragma once

#include "Global.h"

#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
#include <dxerr.h>
#pragma comment(lib, "dxerr.lib")
#include "Object.h"			// for Object:: everything
#include <assert.h>			// for assert()
#include "SpinningObject.h"	// for SpinningObject:: everything
#include "Renderer.h"		// for Renderer:: everything

//#define ROW 6
//#define COL 6
//
//enum SHAPE_TYPE
//{
//	Empty,
//	Circle,
//	Square,
//	Triangle,
//	Hexagon,
//	Oval,
//	Star
//};

/******************************************************************************\
*                                 Shape class                                  *
\******************************************************************************/

class Shape
{
private:
	D3DXMATRIX m_trans;
	int shapeType;
	//float gridX;
	//float gridY;
	//float gridZ;
	//MTRand m_mtrand;		//Mersenne Twister class variable
	int m_max;				//Maximum value
	bool animated;           //turns animate on and off
	/*SpinningObject* pObject1;
	SpinningObject* pObject2;
	SpinningObject* pObject3;
	SpinningObject* pObject4;
	SpinningObject* pObject5;
	SpinningObject* pObject6;*/
	SpinningObject* pObject[SHAPE_SIZE];
	//textures for animation
	//IDirect3DTexture9 * spark1;
	//IDirect3DTexture9 * spark2;
	//IDirect3DTexture9 * spark3;
	//IDirect3DTexture9 * spark4;
	//IDirect3DTexture9 * spark5;
	//pos of sprite/animation
	int posX;
	int posY;
	//counter for animation
	int animCount;
	//bool for anim
	//used to decide on forward or reverse animation
	bool countBool;

public:
	inline static Shape* Instance()
	{
		static Shape theShape;
		return &theShape;
	}
	//init for sprite texture and animated
	void spriteTextureInit()
	{
		animated = false;
		countBool = false;
		animCount = 0;
		//Renderer::Instance()->LoadTextureFile("spark_1.tga",&spark1);
		//Renderer::Instance()->LoadTextureFile("spark_2.tga",&spark2);
		//Renderer::Instance()->LoadTextureFile("spark_3.tga",&spark3);
		//Renderer::Instance()->LoadTextureFile("spark_4.tga",&spark4);
		//Renderer::Instance()->LoadTextureFile("spark_5.tga",&spark5);
		posX = 0;
		posY = 0;
	}
	
	Shape();
	void translateGridLoc(int c, int r) { m_trans = location(c, r); }
	void setSpin(bool);
	void setShapeType(int type) { shapeType = type; }
	int getShapeTyp() { return shapeType; }
	void init();
	//   location();
	SpinningObject* draw();

	void seed(int a_max)	//Seed: takes in argument a_max, for use in  
	{						//seeding our RNG, becoming the range
		m_max = a_max;
	}

	int generate()			//Generate: Creates a random number, with the seed
	{						//being the max. Return value is the random number
		int random = rand()%(m_max+1);
		while(random < 0 || random > (m_max-1))
			random = rand()%m_max;
		return random;
	}
	D3DXMATRIX location(int a_indexX, int a_indexY);
	//functions for setting and getting animate bool
	void setAnimated(bool a){animated = a;}
	bool getAnimated(){return animated;}
	//destructor to delete pointers
	~Shape()
	{
		//spark1->Release();
		//spark2->Release();
		//spark3->Release();
		//spark4->Release();
		//spark5->Release();
	/*	delete pObject1;
		delete pObject2;
		delete pObject3;
		delete pObject4;
		delete pObject5;
		delete pObject6;*/

	}

};